﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Apriori
{
    /// <summary>
    /// Holds transactions. Each Transaction contains its name (which is its ID) and 
    /// List of strings that referes to Product names.
    /// Hashing goods for better performance is still to be done..
    /// </summary>
    class Transaction
    {
        private string name;
        public List<string> goods;

        public Transaction()
        {
            this.name = "";
            this.goods = new List<string>();
        }

        public string Hashgoods()
        {
            string hashcode = "";
            foreach (string g in goods)
            {
                hashcode += g + ",";
            }
            return hashcode;
        }

        public void ChangeName(string n)
        {
            this.name = n;
        }

        public void SetName(string n)
        {
            this.name = n;
        }

        public void AddProduct(String k)
        {
            this.goods.Add(k);
        }

        public override string ToString()
        {
            string print = "";
            print += this.name + " ";
            foreach (String i in this.goods)
            {
                print += i.ToString() + " ";
            }
            return print;
        }

        public string PrintGoods()
        {
            string output = "";
            foreach (String p in goods)
            {
                output += p.ToString() + " ";
            }

            return output;
        }
    }
}
